<h2 class="title">Liste der Wandteile</h2>

<%= link_to 'Neuer Wandteil', new_wall_path if @user.is_schorsch? %>
<div class="content"> <!-- Content start -->
<table>
  <tr>
    <th>Nummer</th>
    <th>Name</th>
    <th>Anzahl-Umlenker</th>
    <th>Anzahl-Routen</th>
    <th>Leichteste Route</th>
    <th>Schwerste Route</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @walls.each do |wall| %>
  <tr>
    <td><%= wall.number %></td>
    <td><%= wall.name %></td>
    <td><%= wall.chains.size %></td>
    <td><%= wall.chains.collect{|x| x.routes.size}.inject( nil ) { |sum,x| sum ? sum+x : x } %></td>
    <td><%= wall.chains.collect{|x| x.routes}.flatten.sort{|x, y| x.grade <=> y.grade}.first.grade.grade if wall.chains.collect{|x| x.routes}.flatten.size > 0 %></td>
    <td><%= wall.chains.collect{|x| x.routes}.flatten.sort{|x, y| y.grade <=> x.grade}.first.grade.grade if wall.chains.collect{|x| x.routes}.flatten.size > 0 %></td>
    <td><%= link_to 'Anzeigen', wall %></td>
    <td><%= link_to 'Editieren', edit_wall_path(wall) if @user.is_schorsch? %></td>
    <td><%= link_to 'Löschen', wall, :confirm => 'Are you sure?', :method => :delete  if @user.is_schorsch?%></td>
  </tr>
<% end %>
</table>

<br />

</div>
